export CP		= cp
export RM		= rm
export MD		= mkdir
export CC		= gcc

export CFLAGS		= -W -Wall
export LIBFLAGS		= -shared
export LNKFLAGS		= -lpthread

export LIBPATH		= lib
export OBJPATH		= obj
export SRCPATH		= src

export VERSION		= 0.7

export DESTDIR		= /usr
export DESTLIB		= $(DESTDIR)/lib
export DESTINC		= $(DESTDIR)/include/CSLP

export LIBNAME		= libcslp.so

export EXEC		= $(LIBPATH)/$(LIBNAME)
export HEADERS		= $(SRCPATH)/IO.h $(SRCPATH)/System.h $(SRCPATH)/CSLP.h
export OBJECT		= $(OBJPATH)/IO.o $(OBJPATH)/System.o

all			: $(EXEC)

$(EXEC)			: $(OBJECT)
	$(CC) $(CFLAGS) -o $@ $(LIBFLAGS) $^ $(LNKFLAGS)

$(LIBPATH)		:
	$(MD) $@

$(OBJPATH)/%.o	: $(SRCPATH)/%.c $(OBJPATH)
	$(CC) -c $< -o $@ $(CFLAGS)

$(OBJPATH)		:
	$(MD) $@

install			: all $(DESTINC) $(HEADERS)
	$(CP) $(EXEC) $(DESTLIB)
	$(CP) $(HEADERS) $(DESTINC)

$(DESTINC)		:
	$(MD) $(DESTINC)

uninstall		: $(DESTINC) $(DESTLIB)
	$(RM) -f $(DESTLIB)/$(LIBNAME)
	$(RM) -f $(DESTINC)/IO.h $(DESTINC)/System.h $(DESTINC)/CSLP.h

.PHONY			: clean mrproper

clean			:
	$(RM) -f $(OBJPATH)/*.o

mrproper		: clean
	$(RM) -f $(EXEC)

